<template>
  <div>
    <h1>商品展示</h1>
    <h2>店A的店：
      <button @click="add_shop">管理店铺商品</button>
    </h2>
    <h2>店铺一的商品信息：</h2>
    <table border="1" cellspacing="0" align="center">
      <tr>
        <td>商品名称</td>
        <td>商品价格</td>
        <td>商品图片</td>
      </tr>
      <tr v-for="i in shops">
        <td>{{ i.name }}</td>
        <td>{{ i.price }}</td>
        <td><img :src="'http://127.0.0.1:8000'+i.pic" alt="" width="120px"></td>
      </tr>
    </table>
    <button v-for="i in numm" @click="get_shop1(i)">{{i}}</button>
  </div>
</template>

<script>
import add_shop from "./add_shop";

export default {
  name: "shop",
  data() {
    return {
      shops: [],
      numm:'',
      userid:localStorage.getItem('userid')
    }
  },
  methods:{
    get_shop1(i){
      this.$axios.get('users/AshopAPI/?cpage='+i)
      .then(res=>{
        this.shops = res.data.list
        this.numm = res.data.numm
      })
    },
    add_shop(){
      if(this.userid){
        this.$router.push({path:'/add_shop'})
      }
      else {
        alert('未登录')
        this.$router.push({path:'/users'})
      }
    }
  },
  mounted() {
    this.get_shop1(1)
    // localStorage.setItem('userid','')
  }
}
</script>

<style scoped>

</style>
